;(function($){
	 $(function(){
    var $orderid=$("input[name='orderid']").val();
    $.ajax({
        type:"POST",
        url:"/shop.php/Home/Order/orderAction",
        data:{"orderid":$orderid},
        dataType:"json",
        success:function(message){
          if (message.status) 
            {
               var $logs=message.logs;
               var  $tbody=$('<tbody></tbody>');
               var $string='';
               $.each($logs,function(key,log){
                $string+="<tr>";
                $string+="<td>"+log.action_user+"</td>";
                $string+="<td>"+log.edittime+"</td>";
                var $status=parseInt(log.status);
                switch($status)
                {
                    case 0:
                      $string+="<td>未确认</td>";
                      $string+="<td>未付款</td>";
                      $string+="<td>未发货</td>";
                      $string+="<td>"+log.action_note+"</td>";
                      break;
                    case 2:
                      $string+="<td>未确认</td>";
                      $string+="<td>未付款</td>";
                      $string+="<td>未发货</td>";
                      $string+="<td>订单已取消</td>";
                      break;
                      case 1:
                      $string+="<td>已确认</td>";
                      $string+="<td>未付款</td>";
                      $string+="<td>未发货</td>";
                       $string+="<td>"+log.action_note+"</td>";
                      break;
                      case 3:
                      $string+="<td>已确认</td>";
                      $string+="<td>已付款</td>";
                      $string+="<td>未发货</td>";
                       $string+="<td>"+log.action_note+"</td>";
                      break;
                      case 6:
                      $string+="<td>已确认</td>";
                      $string+="<td>已付款</td>";
                      $string+="<td>配货中</td>";
                       $string+="<td>"+log.action_note+"</td>";
                      break;
                      case 8:
                      $string+="<td>已确认</td>";
                      $string+="<td>已付款</td>";
                      $string+="<td>已发货</td>";
                       $string+="<td>"+log.action_note+"</td>";
                      break;
                      case 9:
                      $string+="<td>已确认</td>";
                      $string+="<td>已付款</td>";
                      $string+="<td>已收货</td>";
                       $string+="<td>"+log.action_note+"</td>";
                      break;
                
                } 
                
                
                $string+="</tr>"; 
               });
               $tbody.append($string);
               $($tbody).replaceAll(".orderlog tbody");

            }else{
                return '';
            }
        }
    })
  })
  $("form").submit(function(e){
    e.preventDefault();
    var $orderid=$('.orderid').val();
    var $order_amount=$('.amount').val();

    $.ajax({
      type:'POST',
      url:"/shop.php/Home/Order/payOrder",
      data:{'orderid':$orderid,'order_amount':$order_amount},
      dataType:'json',
      success:function(mess){
      // var  result=JSON.parse(msg);
      var status=mess.status;
      if (status !='') {
        alert(mess.msg);
        window.location.reload();
      }else{
        alert(mess.msg);
      }
       
      }
    })
  });
})(jQuery)